package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hiultra.archive.domain.vo.SelectParamsVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArchiveDes;
import com.hiultra.archive.service.IArchiveDesService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 销毁数据Controller
 *
 * @author paidaxing
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/archive/ArchiveDes")
public class ArchiveDesController extends BaseController
{
    @Autowired
    private IArchiveDesService archiveDesService;

    /**
     * 查询销毁数据列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveDes:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveDes archiveDes) throws JsonProcessingException {
        startPage();
        List<ArchiveDes> list = archiveDesService.selectArchiveDesList(archiveDes);
        return getDataTable(list);
    }

    /**
     * 导出销毁数据列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveDes:export')")
    @Log(title = "销毁数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveDes archiveDes) throws JsonProcessingException {
        List<ArchiveDes> list = archiveDesService.selectArchiveDesList(archiveDes);
        ExcelUtil<ArchiveDes> util = new ExcelUtil<ArchiveDes>(ArchiveDes.class);
        util.exportExcel(response, list, "销毁数据数据");
    }

    /**
     * 获取销毁数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveDes:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(archiveDesService.selectArchiveDesById(id));
    }

    /**
     * 新增销毁数据
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveDes:add')")
    @Log(title = "销毁数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveDes archiveDes)
    {
        return toAjax(archiveDesService.insertArchiveDes(archiveDes));
    }

    /**
     * 修改销毁数据
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveDes:edit')")
    @Log(title = "销毁数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveDes archiveDes)
    {
        return toAjax(archiveDesService.updateArchiveDes(archiveDes));
    }

    /**
     * 删除销毁数据
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveDes:remove')")
    @Log(title = "销毁数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(archiveDesService.deleteArchiveDesByIds(ids));
    }
    /**
     * 根据任务id查询销毁档案详情
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveDes:query')")
    @GetMapping(value = "/selectArchiveDesByTaskId/{taskId}")
    public AjaxResult selectArchiveDesByTaskId(@PathVariable("taskId") String taskId)
    {
        return AjaxResult.success(archiveDesService.selectArchiveDesByTaskId(taskId));
    }

    /**
     * 修改销毁任务状态
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveDes:updateArchiveDesTaskStatus')")
    @Log(title = "修改销毁任务状态", businessType = BusinessType.UPDATE)
    @PostMapping("/updateArchiveDesTaskStatus")
    public AjaxResult updateArchiveDesTaskStatus(@RequestParam("taskId") String  taskId,@RequestParam("ids") String[] ids, @RequestParam("localStatus") String localStatus)
    {
        return toAjax(archiveDesService.updateArchiveDesTaskStatus(taskId,ids,localStatus));
    }
}
